package com.chan.web.controller.cd;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.chan.domain.CdDetailetrack;
import com.chan.service.ICdDetailetrackService;
import com.chan.common.annotation.Log;
import com.chan.common.core.controller.BaseController;
import com.chan.common.core.domain.AjaxResult;
import com.chan.common.core.page.TableDataInfo;
import com.chan.common.enums.BusinessType;
import com.chan.common.utils.poi.ExcelUtil;
/**
 * 需求跟踪Controller
 *
 * @author chan
 * @date 2024-04-29
 */
@Controller
@RequestMapping("/cd/detailetrack")
public class CdDetailetrackController extends BaseController
{
    private String prefix = "cd/detailetrack";

    @Autowired
    private ICdDetailetrackService cdDetailetrackService;

    @RequiresPermissions("cd:detailetrack:view")
    @GetMapping()
    public String detailetrack()
    {
        return prefix + "/detailetrack";
    }

    /**
     * 查询需求跟踪列表
     */
    @RequiresPermissions("cd:detailetrack:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CdDetailetrack cdDetailetrack)
    {
        startPage();
        List<CdDetailetrack> list = cdDetailetrackService.selectCdDetailetrackList(cdDetailetrack);
        return getDataTable(list);
    }

    /**
     * 导出需求跟踪列表
     */
    @RequiresPermissions("cd:detailetrack:export")
    @Log(title = "需求跟踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CdDetailetrack cdDetailetrack)
    {
        List<CdDetailetrack> list = cdDetailetrackService.selectCdDetailetrackList(cdDetailetrack);
        ExcelUtil<CdDetailetrack> util = new ExcelUtil<CdDetailetrack>(CdDetailetrack.class);
        return util.exportExcel(list, "需求跟踪数据");
    }

    /**
     * 新增需求跟踪
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存需求跟踪
     */
    @RequiresPermissions("cd:detailetrack:add")
    @Log(title = "需求跟踪", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CdDetailetrack cdDetailetrack)
    {
        return toAjax(cdDetailetrackService.insertCdDetailetrack(cdDetailetrack));
    }

    /**
     * 修改需求跟踪
     */
    @RequiresPermissions("cd:detailetrack:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CdDetailetrack cdDetailetrack = cdDetailetrackService.selectCdDetailetrackById(id);
        mmap.put("cdDetailetrack", cdDetailetrack);
        return prefix + "/edit";
    }

    /**
     * 修改保存需求跟踪
     */
    @RequiresPermissions("cd:detailetrack:edit")
    @Log(title = "需求跟踪", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CdDetailetrack cdDetailetrack)
    {
        return toAjax(cdDetailetrackService.updateCdDetailetrack(cdDetailetrack));
    }

    /**
     * 删除需求跟踪
     */
    @RequiresPermissions("cd:detailetrack:remove")
    @Log(title = "需求跟踪", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cdDetailetrackService.deleteCdDetailetrackByIds(ids));
    }
}
